﻿using System.IO;

namespace Rename.UC.FastOLSV
{
    public class UcFastOlsv文件重命名: UcFastOlsvBase
    {
        private BrightIdeasSoftware.OLVColumn 原文件名 = new BrightIdeasSoftware.OLVColumn();
        private BrightIdeasSoftware.OLVColumn 新文件名 = new BrightIdeasSoftware.OLVColumn();
        private BrightIdeasSoftware.OLVColumn 文件路径 = new BrightIdeasSoftware.OLVColumn();
        private BrightIdeasSoftware.OLVColumn 创建时间 = new BrightIdeasSoftware.OLVColumn();
        private BrightIdeasSoftware.OLVColumn 修改时间 = new BrightIdeasSoftware.OLVColumn();
        private BrightIdeasSoftware.OLVColumn 大小 = new BrightIdeasSoftware.OLVColumn();
        private BrightIdeasSoftware.OLVColumn 状态 = new BrightIdeasSoftware.OLVColumn();

        public UcFastOlsv文件重命名()
        {

        }

        protected override void SetupColumns()
        {
            fastOlsv.AllColumns.Add(this.原文件名);
            this.原文件名.AspectName = "FileName";
            this.原文件名.IsEditable = false;
            this.原文件名.Text = "原文件名";
            this.原文件名.Width = 150;

            this.原文件名.ImageGetter = GetFileIcon;

            fastOlsv.AllColumns.Add(this.新文件名);
            this.新文件名.AspectName = "NewFileName";
            this.新文件名.Text = "新文件名";
            this.新文件名.Width = 150;
            this.新文件名.AutoCompleteEditorMode = System.Windows.Forms.AutoCompleteMode.None;

            fastOlsv.AllColumns.Add(this.文件路径);
            this.文件路径.AspectName = "Path";
            this.文件路径.IsEditable = false;
            this.文件路径.Text = "文件路径";
            this.文件路径.Width = 300;

            fastOlsv.AllColumns.Add(this.创建时间);
            this.创建时间.AspectName = "CrTime";
            this.创建时间.IsEditable = false;
            this.创建时间.Text = "创建时间";
            this.创建时间.Width = 175;

            fastOlsv.AllColumns.Add(this.修改时间);
            this.修改时间.AspectName = "MTime";
            this.修改时间.IsEditable = false;
            this.修改时间.Text = "修改时间";
            this.修改时间.Width = 175;

            fastOlsv.AllColumns.Add(this.大小);
            this.大小.AspectName = "Size";
            this.大小.IsEditable = false;
            this.大小.Text = "大小";
            this.大小.Width = 90;

            fastOlsv.AllColumns.Add(this.状态);
            this.状态.AspectName = "Status";
            this.状态.IsEditable = false;
            this.状态.Text = "状态";
            this.状态.Width = 80;

            base.SetupColumns();

            fastOlsv.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { 原文件名, 新文件名, 文件路径, 创建时间, 修改时间, 大小, 状态, 操作 });
        }

        protected override LsvFileBase AddRow(string file, string rule)
        {
            LsvFile文件重命名 file_info = new LsvFile文件重命名();

            file_info.FileName = Path.GetFileName(file);
            file_info.Path = Path.GetDirectoryName(file);

            file_info.NewFileName = Path.GetFileName(file);
            FileInfo fileInfo = new FileInfo(file);
            file_info.Size = Util.FormatFileSize(fileInfo.Length);
            file_info.CrTime = fileInfo.CreationTime.ToString("yyyy-MM-dd HH:mm:ss");//DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            file_info.MTime = fileInfo.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss");
            return file_info;
        }
    }
}
